<%@page import="com.charlie.sessions.Cart"%>
<%@page import="com.charlie.beans.Product"%>

<%@include file="/header.jsp" %>

<script>
    $(function() {
        $('.buy').click(function() {
            var itemId = parseInt($('#itemId').val());
            var amount = parseInt($('#amount').val());
            if (!itemId)
                return;
            cart_query('add', itemId, amount, null);
        });
        $('#amount').keypress(handle_number_keys);
    });
</script>

<%
Product item = (Product) request.getAttribute("item");
if (item != null) { %>
<div class="white_block">
    <h1>${item.getName()}</h1>
    <img src="/products/large/${item.getImage()}">
</div>



<div class="white_block" >
    <span>
        <center><b>Details</b></center>
        <p class ="wbtext">
            ${item.getDescription()}
        </p>
        Cost: ${item.getCost()} $
        <input type="hidden" id="itemId" value="${item.getProductId()}"><br><br>
        Count 
        <input type="number" id="amount" value="1" min="1" max="<%= Cart.getMaxCost() %>" class="amount_filed"> &nbsp;
        <a href="#" class="buy">Add to cart</a>
    </span>
</div>
<% } %>

<%@include file="/footer.jsp" %>
